<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        管理员列表
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="__STATIC__/admin/css/x-admin.css" media="all">
</head>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>管理员管理</cite></a>
              <a><cite>管理员列表</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                        style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <xblock>
        <button class="layui-btn" onclick="admin_add('添加管理员','admin-add.html','600','500')"><i class="layui-icon">&#xe608;</i>添加
        </button>
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>ID</th>
            <th>登录名</th>
            <th>等级</th>
            <th>登录IP</th>
            <th>最后登录时间</th>
            <th>是否在线</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="adminList" id="vo"}
        <tr>
            <td>{$vo.id}</td>
            <td>{$vo.name}</td>
            <td>
                {if condition = "$vo.lv eq 1"}
                超级管理员
                {else /}
                代理
                {/if}
            </td>
            <td>{$vo.login_ip}</td>
            <td>{$vo.last_time}</td>
            <td>
                {if condition="$vo.on_line > time()"}
                <span style="color: #ff0000">在线</span>
                {else /}
                下线
                {/if}
            </td>
            <td class="td-status">
                {if condition = "$vo.state eq 1"}
                <span class="layui-btn layui-btn-normal layui-btn-mini">
                    已启用
                </span>
                {else /}
                <span class="layui-btn layui-btn-disabled layui-btn-mini">
                    已停用
                </span>
                {/if}
            </td>
            <td class="td-manage">
                {if condition = "$Think.session.admin.lv eq 1"}
                {if condition = "$vo.lv neq 1"}
                <a style="text-decoration:none" onclick="admin_stop('{$vo.id}','{$vo.state}')" href="javascript:;" title="停用">
                    <i class="layui-icon">&#xe601;</i>
                </a>
                {/if}
                {/if}
                <a title="编辑" href="javascript:;" onclick="admin_edit('{$vo.id}')"
                   class="ml-5" style="text-decoration:none">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <!--<a title="删除" href="javascript:;" onclick="admin_del(this,'{$vo.id}')"-->
                   <!--style="text-decoration:none">-->
                    <!--<i class="layui-icon">&#xe640;</i>-->
                <!--</a>-->
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>

</div>
<script src="__STATIC__/admin/lib/layui/layui.js" charset="utf-8"></script>
<script src="__STATIC__/admin/js/x-layui.js" charset="utf-8"></script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer'], function () {
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
    });

    /*添加*/
    function admin_add(title, url, w, h) {
        var url = "{:url('admin/adminAdd')}";
        x_admin_show(title, url, w, h);
    }

    /*停用*/
    function admin_stop(id,state) {
        if(state == 1){
            layer.confirm('确认要停用吗？', function (index) {
                //发异步把用户状态进行更改
                location.href = "{:url('admin/adminStop')}?id="+id+'&state='+state;
            });
        }else if(state == 0){
            layer.confirm('确认要开启吗？', function (index) {
                //发异步把用户状态进行更改
                location.href = "{:url('admin/adminStop')}?id="+id+'&state='+state;
            });

        }
    }


    //编辑
    function admin_edit(id) {
        var title = '编辑';
        var url = "{:url('admin/adminEdit')}?id="+id;
        x_admin_show(title, url,500,400);
    }

    /*删除*/
    function admin_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            //发异步删除数据
            $(obj).parents("tr").remove();
            layer.msg('已删除!', {icon: 1, time: 1000});
        });
    }
</script>
<script>
    var _hmt = _hmt || [];
    (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>
</body>
</html>